//
//  TTBaseViewController.swift
//  TTWeibo
//
//  Created by 陶宏路 on 16/7/19.
//  Copyright © 2016年 陶路路. All rights reserved.
//

import UIKit

class TTBaseViewController: UIViewController{

    let isLogin:Bool = TTOAutoModel.sharedOautoModel.isLogin
    
    let visitorView = TTVisitorView()
    let homeTabBar = TTTabBar()
    
    
    override func loadView() {
        

        isLogin ? (view = tableView): (setUpUI())
    }
    
    func setUpUI(){
        
        view = visitorView
        visitorView.visitorDelegate = self
        setUpButton()

    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
       
        
  }
    
    func setUpButton(){
        
//        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "didClickButotn")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "didClickButotn")
        self.navigationController?.navigationBar.tintColor = UIColor.orangeColor()
        
//   分类 创建leftBarButton
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", imag:nil, target: self, action: "didClickButotn")
        
//   自定义子类
        
//        self.navigationItem.leftBarButtonItem = TTBarButtonItem(title: "登录", imag: nil, target: self, action: "didClickButotn")
    }
    
    lazy var tableView:UITableView = {
       let table = UITableView()
        
        return table
    }()
    
    func didClickButotn(){
        
       presentViewController(UINavigationController(rootViewController: TTOAutoViewController()), animated: true, completion: nil)
        
    }
    
}

extension TTBaseViewController:VisitorViewDelegate{
    
    func LoginButton() {
        
       didClickButotn()
    }

}





